package rollercoaster.railway.tests;

import rollercoaster.commons.Vertex3D;
import rollercoaster.railway.utils.ArrayUtils;
import rollercoaster.railway.utils.VertexUtils;

public class VertexUtilsTest {
	
	public static void main(String[] args) {
		float[][] matrix ={
			{1, 1, 1, 1},
			{2, 2, 2, 2},
			{3, 3, 3, 3},
			{4, 4, 4, 4}
		};
		
		float[][] matrix2 ={
				{1, 1, 1, 1},
				{2, 2, 2, 2, 5},
				{3, 3, 3, 3},
				{4, 4, 4, 4}
		};
		
		ArrayUtils.transpose(matrix);
		
		for (int i = 0; i < matrix.length; i++) {
			for (int j = 0; j < matrix[i].length; j++) {
				System.out.print(matrix[i][j] + " ");
			}
			System.out.print("\n");
		}
		
		ArrayUtils.transpose(matrix2);
		
		float[] vector = {1, 1, 1, 1};
		
		float[] result = ArrayUtils.matrixByVector(matrix, vector);
		
		for (int i = 0; i < result.length; i++) {
			System.out.println(result[i] + " ");
		}
		
		Vertex3D v1=new Vertex3D(1, 1, 0);
		VertexUtils.normalizeVector(v1);
		System.out.println(v1);
		
		Vertex3D v11=new Vertex3D(1, 0, 0);
		Vertex3D v12=new Vertex3D(0, 1, 0);
		Vertex3D v13=VertexUtils.crossProduct(v11, v12);
		System.out.println(v13);
		
		float[][] a={
				{1,2,3},
				{0,1,2},
				{0,0,1}
		};
		float[][] b={
				{-1,0,3,2},
				{0,1,2,0},
				{0,0,1,0}
		};
		
		float[][] c=ArrayUtils.matrixProduct(a, b);
		for (int i = 0; i < c.length; i++) {
			for (int j = 0; j < c[0].length; j++) {
				System.out.print(c[i][j]+" ");
			}
			System.out.println();
		}
		
		float[] v=ArrayUtils.fromMatToVec(a);
		for (int i = 0; i < v.length; i++) {
			System.out.print(v[i]+" ");
		}
		System.out.println();
		float [][] anew=ArrayUtils.fromVecToMat(v, 3, 3);
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[0].length; j++) {
				System.out.print(anew[i][j]+" ");
			}
			System.out.println();
		}
	}
}
